﻿import axios from 'axios'
// 上传文件
import FmUpload from '@/components/common/TheUpload.vue'
// video标签
import VideoUpload from '@/components/Selfdefine/UploadComponent.vue'
import TheVideoPlayer from '@/components/common/TheVideoPlayer.vue'
// 上传图片
import FmUploadPic from '@/components/common/TheUploadPic.vue'
// 富文本、地图、图片位置等部分编辑的弹窗以及可编辑表格中相关的字段类型的弹窗
import EditElementDataDialog from './EditElementDataDialog.vue'
// 查看表格的行数据为文件的弹窗
import ShowUploadFileDialog from '@/components/ShowUploadFileDialog.vue'
// ws事件相关的操作部分
import WSTrigger from '@/components/WebSocketComponents/WebSocketConsole.vue'
// echarts组件
import MyEcharts from '@/components/common/TheEchartsComponents.vue'
import { 
  commonUse_defaultMethod,
  commonUse_changeInherentEventParams,
  commonUse_setWidgetStatus,
  commonUse_changeOutputParams,
  commonUse_getRelatedComponents
} from '@/components/commonUse.js'

export default {
  props: ['widget', 'models', 'rules', 'pageFormInfo', 'changeModels', 'dynamicUid', 'dialogType', 'pageRow', 'pageInit', 'fatherName', 'pPageRow'],
  components: {
    FmUpload, FmUploadPic, EditElementDataDialog, ShowUploadFileDialog, WSTrigger, MyEcharts, VideoUpload, TheVideoPlayer
  },
  data () {
    return {
      dataModel: this.models[this.widget.model],
      // 当前事件的信息
      currentEventInfo: {
        no: '',
        name: '',
        category: '',
        request_parameters: '',
        response_data: ''
      },
      // 判断事件的类型，RequestUrl是以~开头的是本地事件，否则是http事件
      isLocalEvent: true,
      // 事件的请求和响应的数据----api的键/页面展示的键/值/事件编号
      // inputArray----apiKey/pageKey/eventNo
      // outputArray----apiKey/pageKey/value/eventNo
      pagePrimaryObj: {
        inputArray: [],
        outputArray: []
      },
      // 当前执行事件的集合
      currentEventsArray: [],
      // 导入事件的弹窗
      showImportDialog: false,
      // 富文本、地图、图片位置等部分以及可编辑表格中相关的字段类型的弹窗
      editElementObj: null,
      showEditElementDataDialog: false,
      currentPageModelsObj: null,
      // 查看表格行数据上传附件的弹窗
      showUploadFileDialog_visible: false,
      // 点击行的文件路径列表
      currentRowFileList: [],
      // 需要调用ws的弹窗相关的信息
      wsDialogInfo: {
        visible: false,
        title: '',
        wsApiRouter: ''
      }
    }
  },
  created () {
    this.initSingleComponent()
  },
  computed: {
    // 调整表格、树形表格的主表(可编辑表格)的显示和隐藏的栏位--获取表头信息
    getTableColumns: function () {
      let currentTableColumns = []
      if ((this.widget.type === 'table' || this.widget.type === 'table_expand') && this.widget.tableColumn.length) {
        this.widget.tableColumn.forEach(item => {
          if (item.isShow) {
            this.$set(currentTableColumns, currentTableColumns.length, item)
          }
        })
      } else if (this.widget.type === 'editableTable' && this.widget.tableColumns.length) {
        this.widget.tableColumns.forEach(item => {
          if (item.isShow) {
            if (this.pageFormInfo.pageConfig.hadWorkflow && this.dialogType === 'showDetail') {
              // 流程时,查看详细
              item['readonly'] = true
            }
            this.$set(currentTableColumns, currentTableColumns.length, item)
          }
        })
      }
      if (currentTableColumns.length) {
        return currentTableColumns.sort(this.orderByObjAttr('sortNum'))
      } else {
        return []
      }
    },
    // 获取树形表格的从表
    getTableColumns_expandTable: function () {
      let currentTableColumns = []
      if (this.widget.type === 'table_expand' && this.widget.sub_options.tableColumn.length) {
        this.widget.sub_options.tableColumn.forEach(item => {
          if (item.isShow) {
            this.$set(currentTableColumns, currentTableColumns.length, item)
          }
        })
      }
      if (currentTableColumns.length) {
        return currentTableColumns.sort(this.orderByObjAttr('sortNum'))
      } else {
        return []
      }
    }
  },
  methods: {
    // 初始化当组件的方法
    initSingleComponent () {
      if (this.widget.type === 'Select' || this.widget.type === 'MultiSelect' || this.widget.type === 'RadioButton' || this.widget.type === 'CheckBox') {
        // 初始化下拉框的数据来源
        this.getSelectOptions(this.widget, null, null)
      } else if (this.widget.type === 'table' || this.widget.type === 'table_expand') {
        // 初始化表格事件
        this.initTable()
      } else if (this.widget.type === 'StarRate' || this.widget.type === 'SlideInput') {
        // 数字类型
        if (!this.models[this.widget.model] && this.models[this.widget.model] !== 0) {
          this.dataModel = 0
        }
      } else if (this.widget.type === 'editableTable') {
        // 初始化可编辑表格中下拉框的数据来源
        if (this.widget.tableColumns.length) {
          let queryColumns = []
          this.widget.tableColumns.forEach((item, index) => {
            if ((item.ui_type === 'MultiSelect' || item.ui_type === 'Select') && item.isShow) {
              this.getSelectOptions(this.widget, item, index)
            }
            // 获取可编辑的表格需要查询的栏位信息
            if (item.isShow) {
              queryColumns.push(item.indexName)
            }
          })
          // 获取该可编辑表格的全部数据来源
          if (this.pageRow && !this.$isEmptyObject(this.pageRow) && this.pageRow._default_pk) {
            this.getClickRefTableInfo(this.widget, queryColumns)
          }
        }
      }
      // 设置控件的隐藏状态
      if (Object.keys(this.widget.options).indexOf('hiddenExpress') !== -1 && this.widget.options.hiddenExpress) {
        this.widget.options.isHidden = this.setWidgetStatus(this.widget.options.hiddenExpress)
      }
      // 设置控件的只读状态
      if (Object.keys(this.widget.options).indexOf('disabledExpress') !== -1 && this.widget.options.disabledExpress) {
        this.widget.options.disabled = this.setWidgetStatus(this.widget.options.disabledExpress)
      }
    },
    // 初始化级联选择器
    initCascader (node, resolve) {
      if (this.widget.type.indexOf('CascadeSelectMS') !== -1) {
        // 主从表的级联选择器
        if (node.data && node.data.code) {
          if (node.data.leaf) {
            resolve([]) // 叶子节点不需要再获取数据
            return
          }
          // 获取下一级的数据
          this.getCascaderMsData(this.widget, node.data.code, node.level, resolve)
        } else {
          // 第一级时
          this.getCascaderMsData(this.widget, '', '', resolve)
        }
      } else if (this.widget.type.indexOf('CascadeSelectTree') !== -1) {
        // 单表的级联选择器
        if (node.data && node.data.code) {
          // 获取下一级的数据
          this.getCascaderTreeData(this.widget, node.data.code, node.level, resolve)
        } else {
          // 第一级时
          this.getCascaderTreeData(this.widget, '', '', resolve)
        }
      }
    },
    // 获取主从表级联下拉框的内容，逐级获取
    getCascaderMsData (currentElement, rowPk, level, resolve) {
      this.$post('/md_form/cadecase_ms/' + currentElement.metauid + '/' + currentElement.model, {
        is_filter_deleted: Object.keys(currentElement.options).indexOf('isFilterDeleted') !== -1 ? currentElement.options.isFilterDeleted : true,
        parent_pk: rowPk,
        parent_level: level,
        start_level_column: Object.keys(currentElement.options).indexOf('startLevelColumn') !== -1 ? currentElement.options.startLevelColumn : '',
        start_level_value: Object.keys(currentElement.options).indexOf('startLevelValue') !== -1 ? currentElement.options.startLevelValue : '',
        start_meta_name: Object.keys(currentElement.options).indexOf('startMetaName') !== -1 ? currentElement.options.startMetaName : ''
      }).then(data => {
        let dataResult = data.data.result
        if (dataResult.code === 'success') {
          let dataArray = []
          if (dataResult.data.length) {
            dataResult.data.forEach(item => {
              item['children'] = []
              item['leaf'] = dataResult.is_last_level
              item['disabled'] = !item.can_select
              dataArray.push(item)
            })
          }
          resolve(dataArray)
        } else {
          this.$message({
            message: dataResult.msg,
            type: 'error'
          })
        }
      }).catch(error => {
        this.$message({
          message: error,
          type: 'error'
        })
      })
    },
    // 单表级联下拉框
    getCascaderTreeData (currentElement, rowPk, level, resolve) {
      this.$post('/md_form/cadecase_tree/' + currentElement.metauid + '/' + currentElement.model, {
        is_filter_deleted: Object.keys(currentElement.options).indexOf('isFilterDeleted') !== -1 ? currentElement.options.isFilterDeleted : true,
        start_level_column: Object.keys(currentElement.options).indexOf('startLevelColumn') !== -1 ? currentElement.options.startLevelColumn : '',
        start_level_value: Object.keys(currentElement.options).indexOf('startLevelValue') !== -1 ? currentElement.options.startLevelValue : '',
        parent_pk: rowPk,
        parent_level: level,
        fixed_orderby_express: Object.keys(currentElement.options).indexOf('fixedOrderbyExpress') !== -1 ? this.getRequestDataOfGetTableDataMethod(currentElement.options.fixedOrderbyExpress) : '',
        this_data: this.pageRow ? btoa(encodeURIComponent(JSON.stringify(this.pageRow))) : ''
      }).then(data => {
        let dataResult = data.data.result
        if (dataResult.code === 'success') {
          let dataArray = []
          if (dataResult.data.length) {
            dataResult.data.forEach(item => {
              item['children'] = []
              dataArray.push(item)
            })
          }
          resolve(dataArray)
        } else {
          this.$message({
            message: dataResult.msg,
            type: 'error'
          })
        }
      }).catch(error => {
        this.$message({
          message: error,
          type: 'error'
        })
      })
    },
    // 设置控件的只读或者隐藏的状态
    setWidgetStatus (expressJson) {
      // 注：是隐藏、只读表达式，默认显示、可读，则返回 false
      let expressResult = false
      // 常用的固定值的集合
      let fixedValue = {
        formKey: this.dynamicUid,
        limit: 10,
        page: 1
      }
      let submitData = JSON.parse(JSON.stringify(this.models))
      let rowData = null
      let pPageRowData = null
      if (this.pPageRow && !this.$isEmptyObject(this.pPageRow)) {
        submitData = Object.assign(JSON.parse(JSON.stringify(this.pPageRow)), submitData)
        pPageRowData = JSON.parse(JSON.stringify(this.pPageRow))
      }
      if (this.pageRow && !this.$isEmptyObject(this.pageRow)) {
        submitData = Object.assign(JSON.parse(JSON.stringify(this.pageRow)), submitData)
        rowData = JSON.parse(JSON.stringify(this.pageRow))
      }
      expressResult = commonUse_setWidgetStatus(JSON.parse(expressJson), submitData, fixedValue, rowData, pPageRowData)
      return expressResult
    },
    // ----富文本、地图、图片位置等部分数据编辑查看部分--开始
      // 可编辑表格相关的操作
    // 添加数据
    handleAddEditTableData (widget) {
      // 可编辑表格中已有数据
      this.models[widget.model] = this.models[widget.model] ? this.models[widget.model] : []
      if (widget.tableColumns.length) {
        let objExam = {}
        widget.tableColumns.forEach(item => {
          let index = item.indexName
          if (item.isShow) {
            objExam[index] = item.ui_type === 'Switch' ? true : ''
          }
        })
        this.models[widget.model].unshift(objExam)
      }
    },
    // 移除数据
    handleRemoveEditTableData (widget, index) {
      this.$confirm('确定要移除该行数据？', '提示', {
        confirmButtonText: '确定',
        cancelButtonClass: 'el-button--info',
        cancelButtonText: '取消'
      }).then(() => {
        this.models[widget.model].splice(index, 1)
        this.$message({
          message: '移除成功',
          type: 'success'
        })
      }).catch(() => {})
    },
    // 点击某一个单元格时
    rowDataInfo(index, widget, item, row) {
      this.showEditElementDataDialog = true
      this.editElementObj = {
        type: item.ui_type,
        name: item.text,
        model: item.indexName,
        metauid: widget.metauid,
        options: {
          disabled: item.readonly
        },
        editableTableModel: widget.model,
        editableTableClickRowIndex: index
      }
      // 点击行的值的信息
      this.currentPageModelsObj = JSON.parse(JSON.stringify(row))
    },
    // 点击表单中类型为富文本、地图、图片位置等--与可编辑表格中点击的栏位类似
    editElementData (widget) {
      this.showEditElementDataDialog = true
      // 当前控件的信息
      this.editElementObj = JSON.parse(JSON.stringify(widget))
      // 控件所属值的信息
      this.currentPageModelsObj = JSON.parse(JSON.stringify(this.models))
    },
    // 信息编辑成功时
    sureEditElementData (fromChild) {
      this.showEditElementDataDialog = false
      if (this.editElementObj.editableTableModel) {
        // 可编辑表格时
        this.$set(this.models[this.editElementObj.editableTableModel][this.editElementObj.editableTableClickRowIndex], this.editElementObj.model, fromChild)
      } else {
        // 普通的字段信息时--富文本、地图、图片位置等
        this.$set(this.models, this.editElementObj.model, fromChild)
      }
      this.$emit('itemHadChangeModels', this.models)
    },
    // 获取可编辑表格的数据
    getClickRefTableInfo (editableTableWidget, queryColumns) {
      let orderExpress = ''
      if (editableTableWidget.options.fixed_orderby_express) {
        orderExpress = this.getRequestDataOfGetTableDataMethod(editableTableWidget.options.fixed_orderby_express)
      }
      let fixedExpress = {_default_ref: this.models['_default_pk']}
      let refRequestParams = {
        limit: 1000,
        page: 1,
        filter_column: '',
        filter_value: '',
        query_columns: queryColumns.join(','),
        is_filter_deleted: Object.keys(editableTableWidget.options).indexOf('isFilterDeleted') !== -1 ? editableTableWidget.options.isFilterDeleted : true,
        fixed_filter_express: btoa(encodeURIComponent(JSON.stringify(fixedExpress))),
        fixed_orderby_express: orderExpress,
        other_condition_express: ''
      }
      this.$post('/md_form/' + editableTableWidget.metauid + '/query', refRequestParams).then(data => {
        let dataInfo = data.data.result
        if (dataInfo.code === 'success') {
          // this.ruleForm.lessonArray = dataInfo.data
          this.$set(editableTableWidget, 'tableData', dataInfo.data)
          this.$set(this.models, editableTableWidget.model, dataInfo.data)
          this.$emit('itemHadChangeModels', this.models)
        } else {
          this.$message({
            message: dataInfo.msg,
            type: 'error'
          })
        }
      }).catch(error => {
        this.$message({
          message: error,
          type: 'error'
        })
      })
    },
    // 获取下拉框的数据（下拉框或可编辑表格控件、可编辑表格需要获取数据源的栏位、当前栏位的序号）
    getSelectOptions (currentElement, editableTableRow, editableTableRowIndex) {
      // 判断该表格是否指定了元数据表
      if (!currentElement.metauid) {
        this.$message({
          message: '该元素还没有指定元数据表，请在元数据页面管理中进行设置',
          type: 'warning'
        })
        return
      }
      // 获取字段名称
      let columnName = editableTableRow ? editableTableRow.indexName : currentElement.model
      this.$patch('/md_form/pop/' + currentElement.metauid + '/' + columnName, {
        is_filter_deleted: Object.keys(currentElement.options).indexOf('isFilterDeleted') !== -1 ? currentElement.options.isFilterDeleted : true,
        fixed_orderby_express: Object.keys(currentElement.options).indexOf('fixedOrderbyExpress') !== -1 ? this.getRequestDataOfGetTableDataMethod(currentElement.options.fixedOrderbyExpress) : '',
        this_data: btoa(encodeURIComponent(JSON.stringify(this.models)))
      }).then(data => {
        let dataInfo = data.data.result
        if (dataInfo.code === 'success') {
          // 下拉框值的栏位--接口设定时
          if (dataInfo.column_value && dataInfo.column_show.length && dataInfo.column_show[0].column_name) {
            if (dataInfo.data) {
              if (!editableTableRow) {
                // 不是可编辑的表格时
                currentElement.options.remoteOptions = dataInfo.data.map(item => {
                  return {
                    value: item[dataInfo.column_value],
                    label: item[dataInfo.column_show[0].column_name]
                  }
                })
              } else {
                // 可编辑表格的下拉框的数据源
                currentElement.tableColumns[editableTableRowIndex].selectOption = dataInfo.data.map(item => {
                  return {
                    value: item[dataInfo.column_value],
                    label: item[dataInfo.column_show[0].column_name]
                  }
                })
              }
            }
          } else {
            // 没有设定时，就采用页面配置时的设定
            if (dataInfo.data && !editableTableRow) {
              currentElement.options.remoteOptions = dataInfo.data.map(item => {
                return {
                  value: item[currentElement.options.props.value],
                  label: item[currentElement.options.props.label]
                }
              })
            }
          }
        } else {
          this.$message({
            message: dataInfo.msg,
            type: 'error'
          })
        }
      }).catch(error => {
        this.$message({
          message: error,
          type: 'error'
        })
      })
    },
    // -----------初始化表格数据---并获取表格的行事件
    initTable () {
      // 将行事件清空
      this.widget.options.rowEvents = {}
      // 表格的自定义事件
      if (this.pageFormInfo.pageConfig.events.length) {
        this.pageFormInfo.pageConfig.events.forEach(item => {
          this.addTableEvent(item)
        })
      }
      // 表格的初始化事件在固有事件中
      if (this.pageFormInfo.pageConfig.inherentEvents.length) {
        this.pageFormInfo.pageConfig.inherentEvents.forEach(item => {
          // 获取到初始化表格事件
          if (item.eventsType === 'initTable' && item.relatedTag === this.widget.model) {
            this.$store.dispatch('changRouteLoading', true)
            this.getTableData(this.widget, null, null)
          }
          // 获取该表格的行事件----只有isActive的事件才会被添加
          this.addTableEvent(item)
        })
      }
      // 对表格的行事件进行排序
      if (this.widget.options.rowEvents && !this.$isEmptyObject(this.widget.options.rowEvents)) {
        for (let key in this.widget.options.rowEvents) {
          this.widget.options.rowEvents[key].sort(this.orderByObjAttr('actionIndex'))
        }
      }
      // 树形表格时,获取树形表格的行事件
      if (this.widget.type === 'table_expand') {
        // 将行事件清空
        this.widget.sub_options.options.rowEvents = {}
        if (this.widget.sub_options.options.events.length) {
          this.widget.sub_options.options.events.forEach(item => {
            this.getTableEventType(item, 'expandTable')
          })
        }
      }
    },
    // 获取事件的类别
    getTableEventType (item, modelType) {
      let rowEvents = this.widget.type === 'table_expand' ? this.widget.sub_options.options.rowEvents : this.widget.options.rowEvents
      // 需要先判断是否有同类的事件被添加
      let hadSameType = false
      if (!this.$isEmptyObject(rowEvents)) {
        for (let rowEventsKey in rowEvents) {
          // 自定义执行事件
          if (item.eventsType === 'selfDefineTable') {
            if (rowEventsKey === 'slefEvent_' + item.selfName) {
              hadSameType = true
            }
          // 自定义打开弹窗事件
          } else if (item.eventsType === 'selfDefineDialogTable') {
            if (rowEventsKey === 'slefDialog_' + item.selfName) {
              hadSameType = true
            }
          // 自定义打开页面事件
          } else if (item.eventsType === 'selfDefinePageTable') {
            if (rowEventsKey === 'slefPage_' + item.selfName) {
              hadSameType = true
            }
          // 打开系统外的地址
          } else if (item.eventsType === 'selfDefinePageTable_openPage') {
            if (rowEventsKey === 'slefOpenPage_' + item.selfName) {
              hadSameType = true
            }
          // 固有事件
          } else {
            if (rowEventsKey === item.eventsType) {
              hadSameType = true
            }
          }
        }
      }
      // 根据事件的类型进行分类
      if (item.eventsType === 'selfDefineTable') {
        this.addEventToRowEvents(hadSameType, 'slefEvent_' + item.selfName, item, modelType)
      } else if (item.eventsType === 'selfDefineDialogTable') {
        this.addEventToRowEvents(hadSameType, 'slefDialog_' + item.selfName, item, modelType)
      } else if (item.eventsType === 'selfDefinePageTable') {
        this.addEventToRowEvents(hadSameType, 'slefPage_' + item.selfName, item, modelType)
      } else if (item.eventsType === 'selfDefinePageTable_openPage') {
        this.addEventToRowEvents(hadSameType, 'slefOpenPage_' + item.selfName, item, modelType)
      } else {
        this.addEventToRowEvents(hadSameType, item.eventsType, item, modelType)
      }
    },
    // 根据事件类型和关联元素判断该事件是不是表格的
    addTableEvent (item) {
      // 获取该表格的行事件----只有isActive的事件才会被添加
      if (item.relatedTag === this.widget.model && item.eventsType !== 'initTable' && item.isActive) {
        this.getTableEventType(item, 'mainTable')
      }
    },
    // 为表格的rowEvents中添加对应的事件
    addEventToRowEvents (hadSameType, eventsType, item, modelType) {
      if (this.widget.type === 'table_expand' && modelType === 'expandTable') {
        if (!hadSameType && !this.widget.options.rowEvents[eventsType]) {
          this.widget.sub_options.options.rowEvents[eventsType] = []
          this.$set(this.widget.sub_options.options.rowEvents[eventsType], 0, item)
        } else {
          this.$set(this.widget.sub_options.options.rowEvents[eventsType], this.widget.sub_options.options.rowEvents[eventsType].length, item)
        }
      } else {
        if (!hadSameType && !this.widget.options.rowEvents[eventsType]) {
          this.widget.options.rowEvents[eventsType] = []
          this.$set(this.widget.options.rowEvents[eventsType], 0, item)
        } else {
          this.$set(this.widget.options.rowEvents[eventsType], this.widget.options.rowEvents[eventsType].length, item)
        }
      }
    },
    // 获取表格中数据的方法---先判断数据表的基本信息---参数为当前表格对象和检索内容的对象
    getTableData (currentTable, searchInfo, evalIndex) {
      // 查询表格的栏位
      let tableColumn_init = []
      // 判断该表格是否指定了元数据表
      if (!currentTable.metauid) {
        this.$message({
          message: '该页面中的表格还没有指定元数据表，请在元数据页面管理中进行设置',
          type: 'warning'
        })
        this.$store.dispatch('changRouteLoading', false)
        return
      }
      // 判断该表格是否指定了栏位
      if (!currentTable.tableColumn.length) {
        this.$message({
          message: '该页面中的表格还没有指定需要展示的栏位，请在元数据页面管理中进行设置',
          type: 'warning'
        })
        this.$store.dispatch('changRouteLoading', false)
        return
      } else {
        currentTable.tableColumn.forEach(item => {
          tableColumn_init.push(item.indexName)
        })
      }
      // 找到该表格关联的页码
      let relatedPage = null
      if (currentTable.relatedComponents.length) {
        currentTable.relatedComponents.forEach(item => {
          if (item.modelKey && item.relatedType === 'init') {
            relatedPage = commonUse_getRelatedComponents(this.pageFormInfo.list, item.modelKey)
          }
        })
      }
      if (!relatedPage) {
        this.$message({
          message: '该页面中的表格还没有指定关联的页码，请在元数据页面管理中进行设置',
          type: 'warning'
        })
        this.$store.dispatch('changRouteLoading', false)
        return
      }
      // 在固有事件中找到该表格的初始化事件
      let currentInitPageEvent = null
      for (let i = 0; i < this.pageFormInfo.pageConfig.inherentEvents.length; i++) {
        if (this.pageFormInfo.pageConfig.inherentEvents[i].eventsType === 'initTable' && this.pageFormInfo.pageConfig.inherentEvents[i].relatedTag === currentTable.model) {
          currentInitPageEvent = JSON.parse(JSON.stringify(this.pageFormInfo.pageConfig.inherentEvents[i]))
          break
        }
      }
      let requestParams = {
        limit: relatedPage.options.pageSize,
        page: relatedPage.options.currentPage,
        filter_column: '',
        filter_value: '',
        query_columns: tableColumn_init.join(','),
        is_filter_deleted: Object.keys(currentTable.options).indexOf('isFilterDeleted') !== -1 ? currentTable.options.isFilterDeleted : true,
        fixed_filter_express: this.getRequestDataOfGetTableDataMethod(currentInitPageEvent.fixed_filter_express),
        fixed_orderby_express: this.getRequestDataOfGetTableDataMethod(currentInitPageEvent.fixed_orderby_express),
        other_condition_express: this.getRequestDataOfGetTableDataMethod(currentInitPageEvent.other_condition_express)
      }
      // 当有检索条件时
      if (searchInfo && !this.$isEmptyObject(searchInfo)) {
        requestParams.filter_column = searchInfo.filter_column,
        requestParams.filter_value = this.models['$_filter']
        // 当点击的是查询的按钮时，需要将页码恢复初始化(需要从第一页开始查询)
        if (searchInfo.fromSearch) {
          relatedPage.options.currentPage = 1
          requestParams.page = 1
        }
      }
      this.$post('/md_form/' + currentTable.metauid + '/query', requestParams).then(data => {
        let dataInfo = data.data.result
        if (dataInfo.code === 'success') {
          if (evalIndex && this.currentEventsArray.length) {
            // 只有当点击查询按钮获取事件时，才需要判断该事件的执行顺序
            if (evalIndex === this.currentEventsArray.length) {
              this.$store.dispatch('changRouteLoading', false)
            } else {
              // 当还有事件需要执行时
              // 事件编号，事件执行的顺序值，当前元素，触发模式(按钮事件类型)--联动时, 字段名称---可编辑表格的下拉框
              this.getEventsInfoByEventNo(this.currentEventsArray[evalIndex].eventsNo, evalIndex + 1, widget, 'searchInfo', null)
            }
          } else {
            this.$store.dispatch('changRouteLoading', false)
          }
          // 获取表格的数据
          currentTable.tableData = []
          if (dataInfo.data.length) {
            dataInfo.data.forEach(item => {
              item['rowEventHideExpress'] = {}
              // 树形表格时,需要设置展开表的数据源信息
              if (currentTable.type === 'table_expand') {
                item['subTableData'] = []
                item['loading'] = false
                item['subTable_pageSize'] = 10
                item['subTable_currentPage'] = 1
                item['subTable_totalLength'] = 0
              }
              // 判断表格的行事件是否有隐藏的表达式
              if (!this.$isEmptyObject(currentTable.options.rowEvents)) {
                for (let rowEventsItem in currentTable.options.rowEvents) {
                  // 默认情况下，按钮都是显示的--这里是隐藏的表达式
                  item['rowEventHideExpress'][rowEventsItem] = false
                  // 查看详细的按钮一直显示--不需要判断
                  if (rowEventsItem !== 'showDetail') {
                    item['rowEventHideExpress'][rowEventsItem] = this.getRowEventHideExpressMethod(currentTable.options.rowEvents[rowEventsItem], item)
                  }
                }
              }
              this.$set(currentTable.tableData, currentTable.tableData.length, item)
            })
          }
          relatedPage.options.totalLength = dataInfo.total_count
        } else {
          this.$message({
            message: dataInfo.msg,
            type: 'warning'
          })
          this.$store.dispatch('changRouteLoading', false)
        }
      }).catch(error => {
        this.$store.dispatch('changRouteLoading', false)
        this.$message({
          message: error,
          type: 'warning'
        })
      })
    },
    // 获取表格行事件的隐藏的表达式---默认时显示的，即不设置时返回的是 false
    // 表达式的值为json字符串
    // key为本行数据的key，默认情况下多个判断条件为 &&， 当为 || 时，需要在key前加上 $or_ 字符
    // value分两种类型，对象和数组类型，对象类型时，表示该key对应value的多个判断条件 &&，数组就表示多个判断条件 ||
    // 本方法接受两个参数 rowEventArray--该行事件的事件集合，只需要找到一个有 row_express 表达式即可， rowItem--改行的数据集合
    getRowEventHideExpressMethod (rowEventArray, rowItem) {
      // 注：是隐藏表达式，默认显示，则返回 false
      let hideExpressResult = false
      for (let i = 0; i < rowEventArray.length; i++) {
        if (Object.keys(rowEventArray[i]).indexOf('row_express') !== -1 && rowEventArray[i]['row_express']) {
          // 常用的固定值的集合
          let fixedValue = {
            formKey: this.dynamicUid,
            limit: 10,
            page: 1
          }
          let rowData = (this.pageRow && !this.$isEmptyObject(this.pageRow)) ? JSON.parse(JSON.stringify(this.pageRow)) : null
          let pPageRowData = (this.pPageRow && !this.$isEmptyObject(this.pPageRow)) ? JSON.parse(JSON.stringify(this.pPageRow)) : null
          hideExpressResult = commonUse_setWidgetStatus(JSON.parse(rowEventArray[i]['row_express']), rowItem, fixedValue, rowData, pPageRowData)
          break
        }
      }
      return hideExpressResult
    },
    // 获取查询事件的特有的请求参数
    getRequestDataOfGetTableDataMethod (express) {
      let rowObj = (this.pageRow && !this.$isEmptyObject(this.pageRow)) ? JSON.parse(JSON.stringify(this.pageRow)) : null
      let pPageRowObj = (this.pPageRow && !this.$isEmptyObject(this.pPageRow)) ? JSON.parse(JSON.stringify(this.pPageRow)) : null
      let modelsObj = (this.models && !this.$isEmptyObject(this.models)) ? JSON.parse(JSON.stringify(this.models)) : null
      let fixedValue = {
        formKey: this.dynamicUid,
        limit: 10,
        page: 1
      }
      return commonUse_changeInherentEventParams(express, rowObj, modelsObj, fixedValue, pPageRowObj)
    },
    // 底部页码的部分改变时
    handlePaginationChange (val, widget, changeType) {
      let relatedTable = null
      let searchInfo = {}
      // 获取关联的表格
      if (widget.relatedComponents.length) {
        widget.relatedComponents.forEach(item => {
          if (item.modelKey && item.relatedType === 'init') {
            relatedTable = commonUse_getRelatedComponents(this.pageFormInfo.list, item.modelKey)
            searchInfo.filter_column = item.relatedKey ? item.relatedKey.join(',') : item.relatedKey
            searchInfo.fromSearch = false
          }
        })
      }
      if (relatedTable) {
        // 改变当前页码的参数
        widget.options[changeType] = val
        this.$store.dispatch('changRouteLoading', true)
        this.getTableData(relatedTable, searchInfo, null)
      } else {
        this.$message({
          message: '该页面中的页码还没有指定关联的表格，请在元数据页面管理中进行设置',
          type: 'warning'
        })
        this.$store.dispatch('changRouteLoading', false)
        return
      }
    },
    // -----------------表格相关的数据、事件初始化结束
    // 对象数组排序
    orderByObjAttr (key) {
      return function (val1, val2) {
        return val1[key] - val2[key]
      }
    },
    // 通过元素的model找到其绑定的事件
    getEventsByTagModel (tagModel) {
      let targetEventInfoArray = []
      // 现在固有事件中查找
      if (this.pageFormInfo.pageConfig.inherentEvents.length) {
        this.pageFormInfo.pageConfig.inherentEvents.forEach(item => {
          // 找到该元素关联的事件--必须是isActive的事件
          if (item.relatedTag === tagModel && item.isActive) {
            targetEventInfoArray.push(item)
          }
        })
      }
      // 自定义事件
      if (this.pageFormInfo.pageConfig.events.length && tagModel) {
        this.pageFormInfo.pageConfig.events.forEach(item => {
          // 找到该元素关联的事件--必须是isActive的事件
          if (item.relatedTag === tagModel && item.isActive) {
            if (item.eventsType === 'searchInfo' || item.eventsType === 'exportReport' || item.eventsType === 'importReport' || item.eventsType === 'selfDefine_btnEvent' || item.eventsType === 'selfDefine_btnEvent_close') {
              // 在当前页面执行的事件必须指定了事件编号才会加入
              if (item.eventsNo) {
                targetEventInfoArray.push(item)
              }
            } else {
              targetEventInfoArray.push(item)
            }
          }
        })
      }
      targetEventInfoArray = targetEventInfoArray.length ? targetEventInfoArray.sort(this.orderByObjAttr('actionIndex')) : []
      return targetEventInfoArray
    },
    // ------------------------固有化事件
    // 1.表格元素的检索方法----按钮点击检索
    getSearchDataInfo (widget, evalIndex) {
      // 找到关联的表格
      let relatedTable = null
      let searchInfo = {}
      if (widget.relatedComponents.length) {
        widget.relatedComponents.forEach(item => {
          if (item.modelKey && item.relatedType === 'search') {
            relatedTable = commonUse_getRelatedComponents(this.pageFormInfo.list, item.modelKey)
            searchInfo.filter_column = item.relatedKey ? item.relatedKey.join(',') : item.relatedKey
            searchInfo.fromSearch = true
          }
        })
      }
      if (relatedTable) {
        this.getTableData(relatedTable, searchInfo, evalIndex)
      } else {
        this.$message({
          message: '该查询的按钮还没有指定关联的表格，请在元数据页面管理中进行设置',
          type: 'warning'
        })
        this.$store.dispatch('changRouteLoading', false)
        return
      }
    },
    // 2.导出报表的方法
    triggerInherentEventOfExport (widget, evalIndex) {     
      // 找到关联的表格
      let relatedTable = null
      // 展示的栏位
      let query_columns = []
      // 展示的栏位的中文名称
      let query_column_header = []
      // 配置时勾选的栏位
      let configColumns = []
      if (widget.relatedComponents.length) {
        widget.relatedComponents.forEach(item => {
          if (item.modelKey && item.relatedType === 'export') {
            relatedTable = commonUse_getRelatedComponents(this.pageFormInfo.list, item.modelKey)
            configColumns = (item.relatedKey && item.relatedKey.length) ? JSON.parse(JSON.stringify(item.relatedKey)) : []
          }
        })
      }
      if (relatedTable) {
        // 判断该表格是否指定了元数据表
        if (!relatedTable.metauid) {
          this.$message({
            message: '需要导出的表格还没有指定元数据表，请在元数据页面管理中进行设置',
            type: 'warning'
          })
          this.$store.dispatch('changRouteLoading', false)
          return
        }
        // 判断该表格是否指定了栏位
        if (!relatedTable.tableColumn.length || !configColumns.length) {
          this.$message({
            message: '需要导出的表格没有指定需要导出的栏位，请在元数据页面管理中进行设置',
            type: 'warning'
          })
          this.$store.dispatch('changRouteLoading', false)
          return
        } else {
          configColumns.forEach(item => {
            for (let i = 0; i < relatedTable.tableColumn.length; i++) {
              if (item === relatedTable.tableColumn[i].indexName) {
                query_columns.push(relatedTable.tableColumn[i].indexName)
                query_column_header.push(relatedTable.tableColumn[i].text)
                break
              }
            }
          })
        }
        // 导出的方法
        this.$post('/md_form/' + relatedTable.metauid + '/export', {
          file_name: relatedTable.metaname.slice(0, relatedTable.metaname.indexOf('(')),
          filter_column: '',
          filter_value: '',
          query_columns: query_columns.join(','),
          query_column_header: query_column_header.join(','),
          fixed_filter_express: this.getRequestDataOfGetTableDataMethod(this.currentEventsArray[evalIndex - 1].fixed_filter_express),
          fixed_orderby_express: this.getRequestDataOfGetTableDataMethod(this.currentEventsArray[evalIndex - 1].fixed_orderby_express),
          other_condition_express: this.getRequestDataOfGetTableDataMethod(this.currentEventsArray[evalIndex - 1].other_condition_express)
        }).then(data => {
          let dataInfo = data.data.result
          if (dataInfo.code === 'success') {
            if (evalIndex && this.currentEventsArray.length) {
              // 只有当点击查询按钮获取事件时，才需要判断该事件的执行顺序
              if (evalIndex === this.currentEventsArray.length) {
                this.$store.dispatch('changRouteLoading', false)
              } else {
                // 当还有事件需要执行时
                // 事件编号，事件执行的顺序值，当前元素，触发模式(按钮事件类型)--联动时, 字段名称---可编辑表格的下拉框
                this.getEventsInfoByEventNo(this.currentEventsArray[evalIndex].eventsNo, evalIndex + 1, widget, 'exportReport', null)
              }
            } else {
              this.$store.dispatch('changRouteLoading', false)
            }
            let content = decodeURIComponent(dataInfo.file)
            let blobContent = this.toBlob(content, dataInfo.filetype)
            this.downloadblob(blobContent, dataInfo.filename)
          } else {
            this.$message({
              message: dataInfo.msg,
              type: 'error'
            })
            this.$store.dispatch('changRouteLoading', false)
          }
        }).catch(error => {
          this.$store.dispatch('changRouteLoading', false)
          this.$message({
            message: error,
            type: 'error'
          })
        })
      } else {
        this.$message({
          message: '该导出的按钮还没有指定需要导出的表格，请在元数据页面管理中进行设置',
          type: 'warning'
        })
        this.$store.dispatch('changRouteLoading', false)
        return
      }
    },
    // 3.点击表格的查看附件时
    clickRowOfFile (fileList) {
      this.currentRowFileList = (fileList && fileList.length) ? JSON.parse(JSON.stringify(fileList)) : []
      this.showUploadFileDialog_visible = true
    },
    // 根据事件编号获取该事件的key值---需要传递的是事件的编号和该操作所执行的事件顺序值
    getEventKeyByEventNo (targetEventNo, evalIndex) {
      let allDictionary = null
      if (this.currentEventsArray[evalIndex - 1].eventsNo && this.currentEventsArray[evalIndex - 1].eventsNo === targetEventNo) {
        allDictionary = this.currentEventsArray[evalIndex - 1]
      }
      // 每次将this.pagePrimaryObj.inputArray清空
      this.pagePrimaryObj.inputArray = []
      if (allDictionary && !this.$isEmptyObject(allDictionary) && allDictionary.inputDic) {
        // 输入的参数格式为：api中的键名 = 页面展示的键名
        for (let i = 0; i < allDictionary.inputDic.length; i++) {
          if (allDictionary.inputDic[i].inputKey.indexOf('=') !== -1) {
            let dicInputArray = allDictionary.inputDic[i].inputKey.split('=')
            let obj = {
              apiKey: dicInputArray[0],
              pageKey: dicInputArray[1],
              eventNo: targetEventNo
            }
            this.pagePrimaryObj.inputArray.push(obj)
          }
        }
      }
      // 获取输出的参数
      if (allDictionary && !this.$isEmptyObject(allDictionary) && allDictionary.outputDic) {
        // 输出的参数格式为： 页面展示的键名 = api中的键名
        for (let i = 0; i < allDictionary.outputDic.length; i++) {
          if (allDictionary.outputDic[i].outputKey.indexOf('=') !== -1) {
            let dicOutputArray = allDictionary.outputDic[i].outputKey.split('=')
            let hadPushed = false
            // 判断该事件的输出参数是否已经加入过一次
            if (this.pagePrimaryObj.outputArray.length) {
              for (let i = 0; i < this.pagePrimaryObj.outputArray.length; i++) {
                if (targetEventNo === this.pagePrimaryObj.outputArray[i].eventNo && this.pagePrimaryObj.outputArray[i].apiKey === dicOutputArray[1] && this.pagePrimaryObj.outputArray[i].pageKey === dicOutputArray[0]) {
                  hadPushed = true
                }
              }
            }
            if (!hadPushed) {
              let obj = {
                apiKey: dicOutputArray[1],
                pageKey: dicOutputArray[0],
                value: null,
                eventNo: targetEventNo
              }
              this.pagePrimaryObj.outputArray.push(obj)
            }
          }
        }
      }
    },
    // 根据事件编号获取事件详细(事件编号，事件执行的顺序值，当前元素，触发模式(按钮事件的类型)--联动或按钮点击时, 字段名称---可编辑表格的下拉框)
    getEventsInfoByEventNo (eventItemNo, evalIndex, currentEvalElement, triggerType, editTableItem) {
      let submitData = JSON.parse(JSON.stringify(this.models))
      if (this.pPageRow && !this.$isEmptyObject(this.pPageRow)) {
        submitData = Object.assign(JSON.parse(JSON.stringify(this.pPageRow)), submitData)
      }
      if (this.pageRow && !this.$isEmptyObject(this.pageRow)) {
        submitData = Object.assign(JSON.parse(JSON.stringify(this.pageRow)), submitData)
      }
      // 获取该事件的key值
      this.getEventKeyByEventNo(eventItemNo, evalIndex)
      // 获取事件的详细
      this.$get('/events4dform/' + eventItemNo).then(data => {
        let dataInfo = data.data.result
        if (dataInfo.code === 'failed') {
          this.$message({
            message: dataInfo.msg,
            type: 'error'
          })
          this.$store.dispatch('changRouteLoading', false)
        }
        if (dataInfo.code === 'success') {
          this.currentEventInfo = {
            no: dataInfo.data.no,
            name: dataInfo.data.name,
            category: dataInfo.data.category,
            request_parameters: dataInfo.data.request_parameters,
            response_data: dataInfo.data.response_data
          }
          // 需要先判断事件是否为ws事件
          if (this.currentEventInfo.request_parameters) {
            let parametersObj = JSON.parse(this.currentEventInfo.request_parameters)
            if (parametersObj.RequestUrl.indexOf('~') === 0 && parametersObj.RequestMethod === 'WS') {
              // 获取触发事件的parameters
              let evalParamters = {}
              if (this.pagePrimaryObj.inputArray.length) {
                this.pagePrimaryObj.inputArray.forEach(item => {
                  // 找到该事件对应的参数
                  if (item.eventNo === eventItemNo) {
                    // 判断apiKey是否是 Query.key的结构（Query表示的是字段名，key表示的是该对象中的一个属性）
                    if (item.apiKey.indexOf('.') !== -1) {
                      let apiObjString = item.apiKey.split('.')
                      // 需要先判断该对象是否已经存在于evalParamters中
                      if (Object.keys(evalParamters).indexOf(apiObjString[0]) === -1) {
                        evalParamters[apiObjString[0]] = {}
                      }
                      evalParamters[apiObjString[0]][apiObjString[1]] = this.getInputParamsMethods(item.pageKey)
                    } else {
                      evalParamters[item.apiKey] = this.getInputParamsMethods(item.pageKey)
                    }
                  }
                })
              }
              // 修改后的参数--如果有词典表，则获取词典表中的数据值，否者就直接为models中的值
              let parameters = this.$isEmptyObject(evalParamters) ? submitData : evalParamters
              let wsQueryStringArray = []
              if (parametersObj.RequestQueryString && !this.$isEmptyObject(parametersObj.RequestQueryString) && parameters && !this.$isEmptyObject(parameters)) {
                for (let searchKey in parametersObj.RequestQueryString) {
                  for (let parametersKey in parameters) {
                    if (searchKey === parametersKey) {
                      let queryArrayString = searchKey + '=' + parameters[parametersKey]
                      wsQueryStringArray.push(queryArrayString)
                    }
                  }
                } 
              }
              // 获取ws请求的url地址
              let wsApiRouter = parametersObj.RequestUrl.slice(1)
              if (wsQueryStringArray.length) {
                wsApiRouter = wsApiRouter + '?' + wsQueryStringArray.join('&')
              }
              // 触发ws相关的事件
              this.$set(this.wsDialogInfo, 'visible', true)
              this.$set(this.wsDialogInfo, 'title', dataInfo.data.name)
              this.$set(this.wsDialogInfo, 'wsApiRouter', wsApiRouter)
              this.$store.dispatch('changRouteLoading', false)
              return
            } else {
              // 触发事件前修改事件参数
              this.changeEventsInfoBeforeSubmit(eventItemNo, evalIndex, currentEvalElement, triggerType, editTableItem)
            }
          } else {
            this.$message({
              message: '没有获取到触发事件的相关信息',
              type: 'error'
            })
            this.$store.dispatch('changRouteLoading', false)
          }
        }
      }).catch(error => {
        this.$message({
          message: error,
          type: 'error'
        })
        this.$store.dispatch('changRouteLoading', false)
      })
    },
    // 修改输入参数的公共方法
    getInputParamsMethods (pageKey, currentRow) {
      let submitData = JSON.parse(JSON.stringify(this.models))
      if (this.pPageRow && !this.$isEmptyObject(this.pPageRow)) {
        submitData = Object.assign(JSON.parse(JSON.stringify(this.pPageRow)), submitData)
      }
      if (this.pageRow && !this.$isEmptyObject(this.pageRow)) {
        submitData = Object.assign(JSON.parse(JSON.stringify(this.pageRow)), submitData)
      }
      if (currentRow && !this.$isEmptyObject(currentRow)) {
        submitData = Object.assign(JSON.parse(JSON.stringify(currentRow)), submitData)
      }
      let fixedValue = {
        formKey: this.dynamicUid,
        limit: 10,
        page: 1
      }
      let rowData = (this.pageRow && !this.$isEmptyObject(this.pageRow)) ? JSON.parse(JSON.stringify(this.pageRow)) : null
      let pPageRowData = (this.pPageRow && !this.$isEmptyObject(this.pPageRow)) ? JSON.parse(JSON.stringify(this.pPageRow)) : null
      return commonUse_defaultMethod(pageKey, submitData, fixedValue, rowData, pPageRowData)
    },
    // 修改触发事件后，输出参数对应的词典表信息的公共方法
    changeOutputParames (data, eventItemNo) {
      let fixedValue = {
        formKey: this.dynamicUid,
        limit: 10,
        page: 1
      }
      let self = this
      let changeParamsArray = commonUse_changeOutputParams(data, eventItemNo, this.pagePrimaryObj.outputArray, this.models, fixedValue)
      if (changeParamsArray && changeParamsArray.length) {
        changeParamsArray.forEach(item => {
          self.$set(self.pagePrimaryObj.outputArray[item.index], 'value', item.pageValue)
          self.$set(self.models, item.pageKey, item.pageValue)
        })
        // 改变页面models的值
        this.$emit('itemHadChangeModels', this.models)
      }
    },
    // 修改事件的参数----主要是需要修改事件path、search、postData等参数
    changeEventsInfoBeforeSubmit (eventItemNo, evalIndex, currentEvalElement, triggerType, editTableItem) {
      if (this.currentEventInfo.request_parameters) {
        let parametersObj = JSON.parse(this.currentEventInfo.request_parameters)
        // 判断事件的类型，RequestUrl是以~开头的是本地事件，否则是http事件
        if (parametersObj.RequestUrl.indexOf('~') === 0) {
          this.isLocalEvent = true
        } else {
          this.isLocalEvent = false
        }
        // 获取触发事件的parameters
        let evalParamters = {}
        if (this.pagePrimaryObj.inputArray.length) {
          this.pagePrimaryObj.inputArray.forEach(item => {
            // 找到该事件对应的参数
            if (item.eventNo === eventItemNo) {
              // 判断apiKey是否是 Query.key的结构（Query表示的是字段名，key表示的是该对象中的一个属性）
              if (item.apiKey.indexOf('.') !== -1) {
                let apiObjString = item.apiKey.split('.')
                // 需要先判断该对象是否已经存在于evalParamters中
                if (Object.keys(evalParamters).indexOf(apiObjString[0]) === -1) {
                  evalParamters[apiObjString[0]] = {}
                }
                evalParamters[apiObjString[0]][apiObjString[1]] = this.getInputParamsMethods(item.pageKey)
              } else {
                evalParamters[item.apiKey] = this.getInputParamsMethods(item.pageKey)
              }
            }
          })
        }
        // 修改后的参数
        let toEvalMethodJsonString = this.$isEmptyObject(evalParamters) ? '' : evalParamters
        this.triggerInitDataEvents(eventItemNo, evalIndex, currentEvalElement, toEvalMethodJsonString, triggerType, editTableItem)
      }
    },
    // 触发页面自定义事件
    triggerInitDataEvents (eventItemNo, evalIndex, currentEvalElement, parameters, triggerType, editTableItem) {
      if (this.isLocalEvent) {
        this.$post('/events4dform/' + eventItemNo + '/eval', {
          this_data: '',
          parameters: parameters
        }).then(data => {
          let dataInfo = data.data.result
          this.afterEval (dataInfo, evalIndex, currentEvalElement, eventItemNo, triggerType, editTableItem)
        }).catch(error => {
          this.$store.dispatch('changRouteLoading', false)
          this.$message({
            message: error,
            type: 'error'
          })
        })
      } else {
        // http事件的出发方式
        if (this.currentEventInfo.request_parameters) {
          let requestObj = JSON.parse(this.currentEventInfo.request_parameters)
          if (!this.$isEmptyObject(requestObj) && requestObj.RequestUrl && requestObj.RequestMethod) {
            let axiosUrl = requestObj.RequestUrl
            // 改变path
            if (requestObj.RequestPath && !this.$isEmptyObject(requestObj.RequestPath)) {
              // 获取请求的url中的path---将url中的变量的改为获取到的值
              for (let pathKey in requestObj.RequestPath) {
                for (let modelKey in this.models) {
                  if (pathKey === modelKey) {
                    axiosUrl = axiosUrl.replace('{' + pathKey + '}', this.models[pathKey])
                  }
                }
              }
            }
            // 修改query的值
            let axiosQuery = {}
            if (requestObj.RequestQueryString && !this.$isEmptyObject(requestObj.RequestQueryString) && parameters) {
              for (let searchKey in requestObj.RequestQueryString) {
                for (let parametersKey in parameters) {
                  if (searchKey === parametersKey) {
                    axiosQuery[searchKey] = parameters[parametersKey]
                  }
                }
              } 
            }
            // 修改postData的值
            let axiosPostData = {}
            if (requestObj.RequestPostData && !this.$isEmptyObject(requestObj.RequestPostData) && parameters) {
              for (let postKey in requestObj.RequestPostData) {
                for (let parametersKey in parameters) {
                  if (postKey === parametersKey) {
                    axiosPostData[postKey] = parameters[parametersKey]
                  }
                }
              } 
            }
            axios({
              url: axiosUrl,
              method: requestObj.RequestMethod,
              // headers: requestObj.RequestHeader,
              data: axiosPostData,
              params: axiosQuery
            }).then(data => {
              let dataInfo = data.data.result
              this.afterEval (dataInfo, evalIndex, currentEvalElement, eventItemNo, triggerType, editTableItem)
            }).catch(error => {
              this.$store.dispatch('changRouteLoading', false)
              this.$message({
                message: error,
                type: 'error'
              })
            })
          }
        }
      }
    },
    // 事件触发后
    afterEval (dataInfo, evalIndex, currentEvalElement, eventItemNo, triggerType, editTableItem) {
      if (dataInfo.code === 'failed') {
        this.$store.dispatch('changRouteLoading', false)
        this.$message({
          message: dataInfo.msg,
          type: 'error'
        })
      } else if (dataInfo.code === 'success') {
        if (triggerType) {
          // 当为联动触发事件时- 触发事件后修改页面的数据
          if (triggerType === 'changeClickRowData') {
            this.currentEventsArray = []
            this.$store.dispatch('changRouteLoading', false)
            let dataObj = dataInfo.data
            if (this.$isArray(dataInfo.data)) {
              dataObj = dataInfo.data[0]
            }
            // 根据输出词典表，修改dataObj中的值
            for (let i = 0; i < this.pagePrimaryObj.outputArray.length; i++) {
              if (this.pagePrimaryObj.outputArray[i].eventNo === eventItemNo) {
                for (let dKey in dataObj) {
                  // 如果返回的值的某一个键设置的词典表，则将该词典表对于的pageKey设置对于的值并存在返回值的集合中
                  if (this.pagePrimaryObj.outputArray[i].apiKey === dKey) {
                    this.$set(dataObj, this.pagePrimaryObj.outputArray[i].pageKey, dataObj[dKey])
                  }
                }
              }
            }
            // 如果设置了联动元素---将获取的值赋予页面对应的元素
            if (currentEvalElement.options.linkageOption.linkageElements && currentEvalElement.options.linkageOption.linkageElements.length) {
              let linkageElementsArray = currentEvalElement.options.linkageOption.linkageElements
              for (let i = 0; i < linkageElementsArray.length; i++) {
                for (let mKey in this.models) {
                  if (mKey === linkageElementsArray[i]) {
                    this.$set(this.models, mKey, dataObj[mKey])
                  }
                }
              }
              // 改变页面models的值
              this.$emit('itemHadChangeModels', this.models)
            }
          } else if (triggerType === 'searchInfo') {
            // 检索方式时
            // 触发事件后，需要判断获取的值是否需要用到下一个事件中
            this.changeOutputParames(dataInfo.data, eventItemNo)
            // 当该事件执行结束时
            if (evalIndex === this.currentEventsArray.length) {
              this.$store.dispatch('changRouteLoading', false)
            } else {
              // 当还有事件需要执行时
              if (this.currentEventsArray[evalIndex].actionIndex === 0) {
                // 传递的参数包括---当前元素/当前事件执行的顺序
                this.getSearchDataInfo(currentEvalElement, evalIndex + 1)
              } else {
                // 事件编号，事件执行的顺序值，当前元素，触发模式(按钮事件类型)--联动时, 字段名称---可编辑表格的下拉框
                this.getEventsInfoByEventNo(this.currentEventsArray[evalIndex].eventsNo, evalIndex + 1, currentEvalElement, 'searchInfo', null)
              }
            }
          } else if (triggerType === 'exportReport') {
            // 导出报表时
            // 触发事件后，需要判断获取的值是否需要用到下一个事件中
            this.changeOutputParames(dataInfo.data, eventItemNo)
            // 当该事件执行结束时
            if (evalIndex === this.currentEventsArray.length) {
              this.$store.dispatch('changRouteLoading', false)
            } else {
              // 当还有事件需要执行时
              if (this.currentEventsArray[evalIndex].actionIndex === 0) {
                // 传递的参数包括---当前元素/当前事件执行的顺序
                this.triggerInherentEventOfExport(currentEvalElement, evalIndex + 1)
              } else {
                // 事件编号，事件执行的顺序值，当前元素，触发模式(按钮事件类型)--联动时, 字段名称---可编辑表格的下拉框
                this.getEventsInfoByEventNo(this.currentEventsArray[evalIndex].eventsNo, evalIndex + 1, currentEvalElement, 'exportReport', null)
              }
            }
          } else if (triggerType === 'beforeQueryTableData') {
            // 执行事件后再执行查询事件时
            // 触发事件后，需要判断获取的值是否需要用到下一个事件中
            this.changeOutputParames(dataInfo.data, eventItemNo)
            // 当该事件执行结束时---执行查询事件
            if (evalIndex === this.currentEventsArray.length) {
              // 找到关联的表格
              let relatedTable = null
              let searchInfo = {}
              if (currentEvalElement.relatedComponents.length) {
                currentEvalElement.relatedComponents.forEach(item => {
                  if (item.modelKey && item.relatedType === 'search') {
                    relatedTable = commonUse_getRelatedComponents(this.pageFormInfo.list, item.modelKey)
                    searchInfo.filter_column = item.relatedKey ? item.relatedKey.join(',') : item.relatedKey
                    searchInfo.fromSearch = true
                  }
                })
              }
              if (relatedTable) {
                this.getTableData(relatedTable, searchInfo, evalIndex)
              } else {
                this.$message({
                  message: '该按钮还没有指定关联的表格，请在元数据页面管理中进行设置',
                  type: 'warning'
                })
                this.$store.dispatch('changRouteLoading', false)
                return
              }
            } else {
              // 事件编号，事件执行的顺序值，当前元素，触发模式(按钮事件类型)--联动时, 字段名称---可编辑表格的下拉框
              this.getEventsInfoByEventNo(this.currentEventsArray[evalIndex].eventsNo, evalIndex + 1, currentEvalElement, 'beforeQueryTableData', null)
            }
          } else if (triggerType === 'selfDefine_exportEvent') {
            // 自定义导出报表时
            // 触发事件后，需要判断获取的值是否需要用到下一个事件中
            if (dataInfo.data) {
              this.changeOutputParames(dataInfo.data, eventItemNo)
            }
            // 当该事件执行结束时
            if (evalIndex === this.currentEventsArray.length) {
              if (Object.keys(dataInfo).indexOf('file') !== -1 && Object.keys(dataInfo).indexOf('filetype') !== -1 && Object.keys(dataInfo).indexOf('filename') !== -1) {
                // 执行的是导出事件时
                let content = decodeURIComponent(dataInfo.file)
                let blobContent = this.toBlob(content, dataInfo.filetype)
                this.downloadblob(blobContent, dataInfo.filename)
                this.$store.dispatch('changRouteLoading', false)
              } else {
                this.$store.dispatch('changRouteLoading', false)
              }
            } else {
              // 当还有事件需要执行时
              // 事件编号，事件执行的顺序值，当前元素，触发模式(按钮事件类型)--联动时, 字段名称---可编辑表格的下拉框
              this.getEventsInfoByEventNo(this.currentEventsArray[evalIndex].eventsNo, evalIndex + 1, currentEvalElement, 'selfDefine_exportEvent', null)
            }
          } else if (triggerType === 'selfDefine_btnEvent') {
            debugger
            // 自定义事件时
            // 触发事件后，需要判断获取的值是否需要用到下一个事件中
            this.changeOutputParames(dataInfo.data, eventItemNo)
            // 当该事件执行结束时
            if (evalIndex === this.currentEventsArray.length) {
              this.$message({
                message: dataInfo.msg,
                type: 'success'
              })
              this.$store.dispatch('changRouteLoading', false)
            } else {
              // 当还有事件需要执行时
              // 事件编号，事件执行的顺序值，当前元素，触发模式(按钮事件类型)--联动时, 字段名称---可编辑表格的下拉框
              this.getEventsInfoByEventNo(this.currentEventsArray[evalIndex].eventsNo, evalIndex + 1, currentEvalElement, 'selfDefine_btnEvent', null)
            }
          } else if (triggerType === 'selfDefineTable_export') {
            // 表格行事件导出报表时
            // 触发事件后，需要判断获取的值是否需要用到下一个事件中
            if (dataInfo.data) {
              this.changeOutputParames(dataInfo.data, eventItemNo)
            }
            // 当该事件执行结束时
            if (evalIndex === this.currentEventsArray.length) {
              if (Object.keys(dataInfo).indexOf('file') !== -1 && Object.keys(dataInfo).indexOf('filetype') !== -1 && Object.keys(dataInfo).indexOf('filename') !== -1) {
                // 执行的是导出事件时
                let content = decodeURIComponent(dataInfo.file)
                let blobContent = this.toBlob(content, dataInfo.filetype)
                this.downloadblob(blobContent, dataInfo.filename)
                this.$store.dispatch('changRouteLoading', false)
              } else {
                this.$store.dispatch('changRouteLoading', false)
              }
            } else {
              // 当还有事件需要执行时
              // 事件编号，事件执行的顺序值，当前元素，触发模式(按钮事件类型)--联动时, 字段名称---可编辑表格的下拉框
              this.getEventsInfoByEventNo(this.currentEventsArray[evalIndex].eventsNo, evalIndex + 1, currentEvalElement, 'selfDefineTable_export', null)
            }
          }
        }
      }
    },
    // 页面中需要点击的事件部分
    handleCommand (command) {
      this.triggerRowEvent(JSON.parse(command.rowData), command.value, JSON.parse(command.widget))
    },
    // 1.表格行事件
    triggerRowEvent (currentRow, eventItem, currentEvalElement) {
      if (!currentEvalElement.metauid) {
        this.$message({
          message: '该页面中的表格还没有指定元数据表，请在元数据页面管理中进行设置',
          type: 'warning'
        })
        return
      }
      let eventsType = eventItem[0].eventsType
      // 打开弹窗类的行为事件时
      if (eventsType === 'editTable' || eventsType === 'selfDefineDialogTable' || eventsType === 'showDetail') {
        let toParentForm = {
          clickRow: currentRow,
          eventsArray: eventItem,
          metauid: currentEvalElement.type === 'table_expand' ? currentEvalElement.sub_options.metauid : currentEvalElement.metauid
        }
        this.$emit('openDialog', toParentForm)
        // 需要执行的事件时
      } else if (eventsType === 'deleteTable' || eventsType === 'activeTable' || eventsType === 'deactiveTable' || eventsType === 'selfDefineTable') {
        let msg = ''
        switch (eventsType) {
          case 'deleteTable': {
            msg = '此操作将永久删除该行信息, 是否继续?'
            break
          }
          case 'removeTable': {
            msg = '此操作将移除该行信息, 移除后可通过恢复操作进行恢复, 是否继续?'
            break
          }
          case 'recoverTable': {
            msg = '此操作将恢复该行的逻辑删除行为, 是否继续?'
            break
          }
          case 'activeTable': {
            msg = '确定要执行启用操作?'
            break
          }
          case 'deactiveTable': {
            msg = '确定要执行停用操作?'
            break
          }
          default: {
            msg = '确定要执行' + eventItem[0].selfName + '操作?'
            break
          }
        }
        this.$confirm(msg, '提示', {
          confirmButtonText: '确定',
          cancelButtonClass: 'el-button--info',
          cancelButtonText: '取消'
        }).then(() => {
          let toParentForm = {
            clickRow: currentRow,
            eventsArray: eventItem,
            metauid: currentEvalElement.type === 'table_expand' ? currentEvalElement.sub_options.metauid : currentEvalElement.metauid
          }
          this.$emit('handelRowEvents', toParentForm)
        }).catch(() => {})
      } else if (eventsType === 'selfDefinePageTable') {
        // 在新的页面打开
        if (eventItem && eventItem.length && eventItem[0].dialogUid) {
          let path = this.$route.path === '/dashboard/metaWorkflowMenu' ? '/dashboard/metaWorkflowMenuPage' : '/dashboard/metaDynamicMenuPage'
          this.$router.push({
            path: path,
            query: {
              uid: eventItem[0].dialogUid,
              // fatherUid:  this.$route.query.fatherUid ? this.$route.query.fatherUid : this.dynamicUid,
              // fatherName:  this.$route.query.fatherName ? this.$route.query.fatherName : this.fatherName,
              fatherUid: this.dynamicUid,
              fatherName: this.fatherName,
              clickRow: currentRow ? JSON.stringify(currentRow) : ''
            }
          })
        } else {
          this.$message({
            message: '还没有指定需要打开的页面，请前往资源管理进行配置',
            type: 'warning'
          })
        }
      } else if (eventsType === 'selfDefinePageTable_openPage') {
        // 在系统外新的页面打开
        if (eventItem && eventItem.length && eventItem[0].linkUrlExpress) {
          let newUrl = eventItem[0].linkUrlExpress
          if (newUrl.indexOf('?') !== -1) {
            let ResultSearchString = ''
            let baseUrl = newUrl.slice(0, newUrl.indexOf('?'))
            let searchString = newUrl.slice(newUrl.indexOf('?') + 1)
            let searchArray = searchString.split('&')
            for (let i = 0; i < searchArray.length; i++) {
              let searchSingleArray = searchArray[i].split('=')
              let stringS = searchSingleArray[0] + '=' + this.getInputParamsMethods(searchSingleArray[1], currentRow)
              ResultSearchString += stringS
              if (i < searchArray.length - 1) {
                ResultSearchString += '&'
              }
            }
            let resultPageUrl = baseUrl + '?' + ResultSearchString
            window.open(resultPageUrl, '_blank')
          } else {
            window.open(newUrl, '_blank')
          }
        } else {
          this.$message({
            message: '还没有指定需要打开的页面，请前往资源管理进行配置',
            type: 'warning'
          })
        }
      } else if (eventsType === 'selfDefineTable_export') {
        // 表格行的导出事件时
        let msg = '确定要执行导出操作?'
        this.$confirm(msg, '提示', {
          confirmButtonText: '确定',
          cancelButtonClass: 'el-button--info',
          cancelButtonText: '取消'
        }).then(() => {
          this.currentEventsArray = eventItem
          if (this.currentEventsArray.length && this.currentEventsArray[0].eventsNo) {
            // 自定义导出按钮时
            this.$store.dispatch('changRouteLoading', true)
            // 事件编号，事件执行的顺序值，当前元素，触发模式(按钮事件类型)--联动时, 字段名称---可编辑表格的下拉框
            this.getEventsInfoByEventNo(this.currentEventsArray[0].eventsNo, 1, currentEvalElement, 'selfDefineTable_export', null)
          } else {
            this.$message({
              message: '该操作没有指定事件，请在元数据页面管理中进行设置',
              type: 'error'
            })
          }
        }).catch(() => {})
      }
    },
    // 2.按钮点击事件
    triggerClickEvent (widget) {
      // 根据元素的model获取其绑定的事件
      if (!widget.model) {
        return
      }
      // 获取当前的事件集合
      this.currentEventsArray = this.getEventsByTagModel(widget.model)
      if (this.currentEventsArray && this.currentEventsArray.length) {
        if (this.currentEventsArray[0].eventsType === 'addDialogForm' || this.currentEventsArray[0].eventsType === 'editDialogForm') {
          // 新增或者编辑的带有弹窗的事件
          let toParentForm = {
            clickRow: (this.pageRow && !this.$isEmptyObject(this.pageRow)) ? JSON.parse(JSON.stringify(this.pageRow)) : '',
            eventsArray: JSON.parse(JSON.stringify(this.currentEventsArray))
          }
          this.$emit('openDialog', toParentForm)
        } else if (this.currentEventsArray[0].eventsType.indexOf('extend_') !== -1 || this.currentEventsArray[0].eventsType === 'submitForm_edit' || this.currentEventsArray[0].eventsType === 'submitDialogForm_edit' || this.currentEventsArray[0].eventsType === 'submitForm_add' || this.currentEventsArray[0].eventsType === 'submitDialogForm_add') {
          // 提交表单事件
          let toParentForm = {
            eventsArray: JSON.parse(JSON.stringify(this.currentEventsArray))
          }
          this.$emit('getFormData', toParentForm)
        } else if (this.currentEventsArray[0].eventsType === 'resetForm' || this.currentEventsArray[0].eventsType === 'resetDialogForm') {
          // 取消提交的事件
          let toParentForm = {
            eventsArray: JSON.parse(JSON.stringify(this.currentEventsArray))
          }
          this.$emit('resetFormData', toParentForm)
        } else if (this.currentEventsArray[0].eventsType === 'selfDefine_btnEvent_close') {
          // 自定义按钮事件,执行完成后需要关闭弹窗
          let toParentForm = {
            eventsArray: JSON.parse(JSON.stringify(this.currentEventsArray))
          }
          this.$emit('tirggerSelfdefineEventClose', toParentForm)
        } else if (this.currentEventsArray[0].eventsType === 'searchInfo') {
          this.$store.dispatch('changRouteLoading', true)
          // 检索按钮时
          if (this.currentEventsArray[0].actionIndex === 0) {
            // 传递的参数包括---当前元素/当前事件执行的顺序
            this.getSearchDataInfo(widget, 1)
          } else {
            // 事件编号，事件执行的顺序值，当前元素，触发模式(按钮事件类型)--联动时, 字段名称---可编辑表格的下拉框
            this.getEventsInfoByEventNo(this.currentEventsArray[0].eventsNo, 1, widget, 'searchInfo', null)
          }
        } else if (this.currentEventsArray[0].eventsType === 'exportReport') {
          this.$store.dispatch('changRouteLoading', true)
          // 导出按钮时
          if (this.currentEventsArray[0].actionIndex === 0) {
            // 传递的参数包括---当前元素/当前事件执行的顺序
            this.triggerInherentEventOfExport(widget, 1)
          } else {
            // 事件编号，事件执行的顺序值，当前元素，触发模式(按钮事件类型)--联动时, 字段名称---可编辑表格的下拉框
            this.getEventsInfoByEventNo(this.currentEventsArray[0].eventsNo, 1, widget, 'exportReport', null)
          }
        } else if (this.currentEventsArray[0].eventsType === 'beforeQueryTableData') {
          this.$store.dispatch('changRouteLoading', true)
          // 排课按钮时---先执行事件，再查询页面数据时
          // 事件编号，事件执行的顺序值，当前元素，触发模式(按钮事件类型)--联动时, 字段名称---可编辑表格的下拉框
          this.getEventsInfoByEventNo(this.currentEventsArray[0].eventsNo, 1, widget, 'beforeQueryTableData', null)
        } else if (this.currentEventsArray[0].eventsType === 'selfDefine_exportEvent') {
          this.$store.dispatch('changRouteLoading', true)
          // 自定义导出按钮时
          // 事件编号，事件执行的顺序值，当前元素，触发模式(按钮事件类型)--联动时, 字段名称---可编辑表格的下拉框
          this.getEventsInfoByEventNo(this.currentEventsArray[0].eventsNo, 1, widget, 'selfDefine_exportEvent', null)
        } else if (this.currentEventsArray[0].eventsType === 'selfDefine_btnEvent') {
          this.$store.dispatch('changRouteLoading', true)
          // 自定义按钮事件时
          // 事件编号，事件执行的顺序值，当前元素，触发模式(按钮事件类型)--联动时, 字段名称---可编辑表格的下拉框
          this.getEventsInfoByEventNo(this.currentEventsArray[0].eventsNo, 1, widget, 'selfDefine_btnEvent', null)
        } else if (this.currentEventsArray[0].eventsType === 'selfDefinePage') {
          // 在新的页面打开
          if (this.currentEventsArray[0].dialogUid) {
            let path = this.$route.path === '/dashboard/metaWorkflowMenu' ? '/dashboard/metaWorkflowMenuPage' : '/dashboard/metaDynamicMenuPage'
            this.$router.push({
              path: path,
              query: {
                uid: this.currentEventsArray[0].dialogUid,
                // fatherUid:  this.$route.query.fatherUid ? this.$route.query.fatherUid : this.dynamicUid,
                // fatherName:  this.$route.query.fatherName ? this.$route.query.fatherName : this.fatherName,
                fatherUid: this.dynamicUid,
                fatherName: this.fatherName,
                clickRow: ''
              }
            })
          } else {
            this.$message({
              message: '还没有指定需要打开的页面，请前往资源管理进行配置',
              type: 'warning'
            })
          }
        } else if (this.currentEventsArray[0].eventsType === 'selfDefinePage_openPage') {
          // 在系统外新的页面打开
          if (this.currentEventsArray[0].linkUrlExpress) {
            let newUrl = this.currentEventsArray[0].linkUrlExpress
            if (newUrl.indexOf('?') !== -1) {
              let ResultSearchString = ''
              let baseUrl = newUrl.slice(0, newUrl.indexOf('?'))
              let searchString = newUrl.slice(newUrl.indexOf('?') + 1)
              let searchArray = searchString.split('&')
              for (let i = 0; i < searchArray.length; i++) {
                let searchSingleArray = searchArray[i].split('=')
                let stringS = searchSingleArray[0] + '=' + this.getInputParamsMethods(searchSingleArray[1])
                ResultSearchString += stringS
                if (i < searchArray.length - 1) {
                  ResultSearchString += '&'
                }
              }
              let resultPageUrl = baseUrl + '?' + ResultSearchString
              window.open(resultPageUrl, '_blank')
            } else {
              window.open(newUrl, '_blank')
            }
          } else {
            this.$message({
              message: '还没有指定需要打开的页面，请前往资源管理进行配置',
              type: 'warning'
            })
          }
        }
      } else {
        this.$message({
          message: '该标签还没有设置任何事情，请在动态表单配置中查看详细',
          type: 'warning'
        })
      }
    },
    // 某一个值变化时的联动操作
    setLinkageOptions (linkageOption, widget) {
      // 触发事件的方式进行联动
      if (linkageOption.linkageType === 'eventRender' && this.dialogType !== 'showDetail') {
        if (linkageOption.linkageEvents) {
          let eventsObj = {
            inputDic: linkageOption.inputDic,
            outputDic: linkageOption.outputDic,
            eventsNo: linkageOption.linkageEvents
          }
          this.$set(this.currentEventsArray, 0, eventsObj)
          this.getEventsInfoByEventNo(linkageOption.linkageEvents, 1, widget, 'changeClickRowData', null)
        } else {
          this.$message({
            message: '该字段为联动字段(数据渲染模式)，但尚未设置联动的方法，请前往资源管理进行设置',
            type: 'warning'
          })
        }
      } else if (linkageOption.linkageType === 'expressionRender' && this.dialogType !== 'showDetail' && Object.keys(linkageOption).indexOf('expressionArray') !== -1) {
        // 数据计算的方式触发事件
        if (!linkageOption.expressionArray.length) {
          let msg = '该字段为联动字段(数据计算模式)，但尚未设置计算表达式或计算字段（或表达式格式不正确），请前往资源管理进行设置'
          this.$message({
            message: msg,
            type: 'warning'
          })
        } else {
          this.$nextTick(() => {
            linkageOption.expressionArray.forEach(item => {
              if (item.expression.indexOf('=') !== -1) {
                let expression = item.expression.split('=')
                // 替换表达式中的符号
                let expressionSymolReplace = expression[1].replace(/\{\+\}/g, '+').replace(/\{-\}/g, '-').replace(/\{\/\}/g, '/').replace(/\{\*\}/g, '*').replace(/\{EQ\}/g, '=')
                // 通过计算字段，修改表达式中对应的值
                for (let i = 0; i < item.expressionElements.length; i++) {
                  let val = this.models[item.expressionElements[i]]
                  // 当该表达式的值没有时，默认设置为空
                  let replaceVal = 0
                  if (val) {
                    replaceVal = val
                    if (typeof(val) === 'string') {
                      replaceVal = '"' + val + '"'
                    }
                    // 值小于0时，避免出现--，/-等情况
                    if (val < 0) {
                      replaceVal = '(' + val + ')'
                    }
                  }
                  expressionSymolReplace = expressionSymolReplace.replace(new RegExp('{' + item.expressionElements[i] + '}', 'g'), replaceVal)
                }
                // 通过表达式获取到计算后的值
                if (expressionSymolReplace) {
                  let resultNumber = this.$selfdefineEval(expressionSymolReplace)
                  if (resultNumber === Infinity || resultNumber === -Infinity || isNaN(resultNumber)) {
                    resultNumber = null
                  }
                  this.$set(this.models, expression[0], resultNumber)
                  // 改变页面models的值
                  this.$emit('itemHadChangeModels', this.models)
                }
              }
            })
          })
        }
      } else if (linkageOption.linkageType === 'showRender' && this.dialogType !== 'showDetail') {
        this.$nextTick(() => {
          // 显示和隐藏时
          for (let i = 0; i < linkageOption.showExpression.length; i++) {
            if (linkageOption.showExpression[i].linkageElement && linkageOption.showExpression[i].showExpress) {
              let showExpress = linkageOption.showExpression[i].showExpress
              showExpress = showExpress.replace(/\{EQ\}/g, '=')
              if (linkageOption.showExpression[i].variableElement) {
                for (let t = 0; t < linkageOption.showExpression[i].variableElement.length; t++) {
                  let val = this.models[linkageOption.showExpression[i].variableElement[t]]
                  // 当该表达式的值没有时，默认设置为空
                  let replaceVal = null
                  if (val) {
                    replaceVal = val
                    if (typeof(val) === 'string') {
                      replaceVal = '"' + val + '"'
                    }
                  }
                  showExpress = showExpress.replace(new RegExp('{' + linkageOption.showExpression[i].variableElement[t] + '}', 'g'), replaceVal)
                }
              }
              // 获取关联显示元素的显示或隐藏的条件
              let hiddenCondition = !this.$selfdefineEval(showExpress)
              let changeStatusElement = commonUse_getRelatedComponents(this.pageFormInfo.list, linkageOption.showExpression[i].linkageElement)
              this.$set(changeStatusElement.options, 'isHidden', hiddenCondition)
            }
          }
        })
      }
    },
    // 导出报表相关的
    downloadblob (blobcontent, filename) {
      if ('msSaveOrOpenBlob' in navigator) {
        // Microsoft Edge and Microsoft Internet Explorer 10-11
        window.navigator.msSaveOrOpenBlob(blobcontent, filename)
      } else {
        // 创建隐藏的可下载链接
        var eleLink = document.createElement('a')
        eleLink.download = filename
        eleLink.style.display = 'none'
        // 字符内容转变成blob地址
        eleLink.href = URL.createObjectURL(blobcontent)
        // 触发点击
        document.body.appendChild(eleLink)
        eleLink.click()
        // 然后移除
        document.body.removeChild(eleLink)
      }
    },
    // 将base64装为excel
    toBlob (base64str, filetype) {
      let bytes = window.atob(base64str)
      let n = bytes.length
      let u8arr = new Uint8Array(n)
      while (n--) {
        u8arr[n] = bytes.charCodeAt(n)
      }
      return new Blob([u8arr], {type: filetype})
    },
    // 导入文件成功时，需要刷新当前页面
    closeUploadDialogSuccess () {
      this.showImportDialog = false
      // 刷新当前页面
      this.$emit('reloadCurrentPage')
    },
    // 点击树形表格的展开或收缩按钮时
    expandTableChange (row, expandRow) {
      if (expandRow && expandRow.length) {
        // 展开表格时
        this.getExpandTableData(this.widget, row)
      }
    },
    // 子表切换页码时
    handleExpandPaginationChange (val, row, widget, type) {
      row[type] = val
      this.getExpandTableData(widget, row)
    },
    // 获取子表的表达式的参数
    getExpandTableinitExpressValue (express, row) {
      if (!express) {
        return ''
      }
      let rowObj = (row && !this.$isEmptyObject(row)) ? JSON.parse(JSON.stringify(row)) : null
      let pPageRowObj = (this.pPageRow && !this.$isEmptyObject(this.pPageRow)) ? JSON.parse(JSON.stringify(this.pPageRow)) : null
      let modelsObj = (this.models && !this.$isEmptyObject(this.models)) ? JSON.parse(JSON.stringify(this.models)) : null
      let fixedValue = {
        formKey: this.dynamicUid,
        limit: 10,
        page: 1
      }
      return commonUse_changeInherentEventParams(express, rowObj, modelsObj, fixedValue, pPageRowObj)
    },
    // 获取子表的数据
    getExpandTableData (widget, row) {
      if (widget.metauid === widget.sub_options.pmetauid && widget.sub_options.metauid) {
        row.loading = true
        let fixedExpress = { _default_ref: row._default_pk }
        // 获取子表的数据
        this.$post('/md_form/' + widget.sub_options.metauid + '/query', {
          limit: widget.sub_options.options.showPageInfo ? row.subTable_pageSize : 10000, // 如果设置不展示页面,就默认查询10000笔资料
          page: widget.sub_options.options.showPageInfo ? row.subTable_currentPage : 1,
          filter_column: '',
          filter_value: '',
          query_columns: '',
          is_filter_deleted: widget.sub_options.options.isFilterDeleted,
          // 子表的初始化事件必须有固定过滤条件表达式{ _default_ref: row._default_pk }
          fixed_filter_express: this.getExpandTableinitExpressValue(widget.sub_options.options.fixed_filter_express, row) ? this.getExpandTableinitExpressValue(widget.sub_options.options.fixed_filter_express, row) : btoa(encodeURIComponent(JSON.stringify(fixedExpress))),
          fixed_orderby_express: this.getExpandTableinitExpressValue(widget.sub_options.options.fixed_orderby_express, row),
          other_condition_express: this.getExpandTableinitExpressValue(widget.sub_options.options.other_condition_express, row)
        }).then((data) => {
          let dataResult = data.data.result
          if (dataResult.code === 'success') {
            row.subTableData = []
            row.subTable_currentPage = dataResult.page
            row.subTable_pageSize = dataResult.limit
            row.subTable_totalLength = dataResult.total_count
            if (dataResult.data.length) {
              dataResult.data.forEach(item => {
                item['rowEventHideExpress'] = {}
                // 判断表格的行事件是否有隐藏的表达式
                if (!this.$isEmptyObject(widget.sub_options.options.rowEvents)) {
                  for (let rowEventsItem in widget.sub_options.options.rowEvents) {
                    // 默认情况下，按钮都是显示的--这里是隐藏的表达式
                    item['rowEventHideExpress'][rowEventsItem] = false
                    // 查看详细的按钮一直显示--不需要判断
                    if (rowEventsItem !== 'showDetail') {
                      item['rowEventHideExpress'][rowEventsItem] = this.getRowEventHideExpressMethod(widget.sub_options.options.rowEvents[rowEventsItem], item)
                    }
                  }
                }
                this.$set(row.subTableData, row.subTableData.length, item)
              })
            }
          } else {
            this.$message({
              message: '获取子表数据失败',
              type: 'warning'
            })
          }
          row.loading = false
        }).catch (error => {
          console.log(error)
          this.$message({
            message: '获取子表数据失败',
            type: 'warning'
          })
          row.loading = false
        })
      } else {
        this.$message({
          message: '未配置子表或者子表与主表不匹配,请重新配置',
          type: 'warning'
        })
      }
    }
  },
  watch: {
    // 监听页面元素的值的改变
    dataModel: {
      deep: true,
      handler (val) {
        this.models[this.widget.model] = val
        this.$emit('itemHadChangeModels', this.models)
        if (Object.keys(this.widget.options).indexOf('linkageOption') !== -1 && this.widget.options.linkageOption.isLinkage && this.dialogType !== 'showDetail') {
          if (((this.widget.type.indexOf('Input') === -1 || this.widget.options.linkageOption.linkageType !== 'eventRender') && this.widget.type !== 'Money') || this.widget.options.linkageOption.linkageType === 'showRender') {
            this.setLinkageOptions(this.widget.options.linkageOption, this.widget)
          }
        }
      }
    },
    // 当页面中数据改变时，需要更新
    changeModels: {
      handler: function (val) {
        if (!this.$isEmptyObject(this.models)) {
          this.dataModel = this.models[this.widget.model]
        }
      },
      deep: true
    },
    // 当页面有初始化事件时,需要重新渲染组件
    pageInit: {
      handler: function () {
        this.$nextTick(() => {
          this.initSingleComponent()
        })
      },
      deep: true
    }
  }
}